<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>延大创新期末成绩登陆小窗口</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" media="all"/>
    <script src="https://www.layuicdn.com/layui/layui.js"></script>

</head>
<body>
<form class="layui-form">
    <div class="layui-form-item" style="    margin-top: 10px;
    margin-right: 10px;">
        <label class="layui-form-label">学号</label>
        <div class="layui-input-block">
            <input type="text" name="username" value="" placeholder="请输入学号">
        </div>
    </div>
    <div class="layui-form-item" style="    margin-top: 10px;
    margin-right: 10px;">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" value="" placeholder="请输入密码">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="create" class="layui-btn" type="button" onclick="bindAccount()">查询
            </button>
        </div>
    </div>
</form>

</body>

<script>

    function bindAccount() {
        var username = $("input[name=username]").val();
        var password = $("input[name=password]").val();
        var school = 13683;
        $.post('/api/login', {username: username, password: password, school: school},
            function (ret) {
                console.log(ret)
                if (ret.code == 200) {
                    layer.msg('登陆成功...',{ icon:1, shade:0.4 },function(){
                        console.log(">>>>success")
                        window.location.href = '/api/queryScore';
                    })

                }else{
                    layer.msg(ret.data,{ icon:2, shade:0.4 });
                }
            });
    }
    layui.use('form', function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

        //……

        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();
    });
</script>
</html>